package online.shenme.day14;

import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicIntegerArray;

public class ExecutorServiceTest {
    public static void main(String[] args) throws InterruptedException {
         ThreadPoolExecutor  service=new ThreadPoolExecutor(
                2,5,100,
                TimeUnit.MILLISECONDS,
                new ArrayBlockingQueue<>(10),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.CallerRunsPolicy());
        for (int i = 0; i < 100; i++) {
            int finalI = i;
            service.submit(()-> System.out.println(Thread.currentThread().getName()+"执行"+ finalI));
        }
        Thread.sleep(10);
        service.submit(()-> System.out.println(service));
        service.shutdown();
        System.out.println(new AtomicIntegerArray(10));
    }
}
